<?php
namespace api\helpers;

/**
 * User: ziwen
 * Date: 2016/1/28 16:11
 * File: ArrayHelper.php
 * Desc: ""
 */
class SmsHelper {
    public static function getTemplateKeyByTcodeAndLanguage($tcode,$language)
    {
        if(!$tcode) return false;
        $fileName = \yii::getAlias('@configPath').'/emailforge4_config.php';
        if(file_exists($fileName)){
            $configArr = include $fileName;
            $language = trim($language) ? strtolower($language) : 'en';

            $templateKey = isset($configArr[$tcode][$language]) ? $configArr[$tcode][$language] : $configArr[$tcode]['en'];
            return $templateKey;
        }else{
            return false;
        }
    }

    /**
     * @param $varname
     * @desc 获取emailforge4_filed_config.php上对应的值,主要用于变量的替换
     * @author ziwen  20150910
     */
    public static function getPositionByName($keyname){
        if(!$keyname) return false;
        $fileName = \yii::getAlias('@configPath').'/emailforge4_filed_config.php';
        if(file_exists($fileName)){
            $configArr = include $fileName;
            if(false != ($templateKey=array_search($keyname,$configArr))){
                return $templateKey;
            }
            return false;
        }else{
            return false;
        }
    }

    public static function pr($data)
    {
        echo '<pre>';
        print_r($data);
        echo '</pre>';
        exit;
    }
}